//员工状态格式化
function userStateFormatter(value,row,index){
    if(value==0){
        return '<span style="color: green">正常</span>';
    }else if(value==1){
        return '<span style="color: red">停用</span>';
    }else{
        return "";
    }
}

function taskStateFormatter(value,row,index) {
  if(value==1){
    return '<span style="color:red">没人认领</span>';
  }else if(value==2){
    return '<span style="color:orange">已通过（同意）</span>';
  }else if(value==3){
    return '<span style="color:green">已拒绝</span>';
  }else if(value==4){
    return '<span style="color:cornflowerblue">已作废</span>';
  }
}
//员工状态格式化
function permissionStateFormatter(value,row,index){
  if(value==1){
    return '<span style="color: green">正常</span>';
  }else if(value==-1){
    return '<span style="color: red">停用</span>';
  }else{
    return "";
  }
}

//对象格式化
function objectFormatter(value,row,index){
    return value?value.name||value.realname:"";
}

//序列化表单json
$.fn.serializeJSON = function(){
    var serializeArr = $(this).serializeArray();
    //console.debug(serializeArr);
    var param = {};
    $.each(serializeArr,function(index,obj){
        param[obj.name] = obj.value;
    });
    return param;
}

//数组的克隆
function arrClone(arr){
    var newArr = [];//创建一个空数组
    for(var i in arr){
        var ele = arr[i];
        var newEle = {};
        $.extend(newEle,ele);
        newArr.push(newEle);
    }
    return newArr;
}

$.extend($.fn.validatebox.defaults.rules, {
  /*必须和某个字段相等*/
  equalTo: { validator: function (value, param) { return $(param[0]).val() == value; }, message: '字段不匹配' }
});
